package com.ruoyi;

import com.ruoyi.web.core.ColorfulUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableAsync
public class RuoYiApplication
{

    public static ApplicationContext applicationContext;

    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        applicationContext = SpringApplication.run(RuoYiApplication.class, args);
        // bannerRuoyi();
        bannerBusiness();
    }

    public static void close(ApplicationContext context)
    {
        if (context instanceof ConfigurableApplicationContext)
        {
            ConfigurableApplicationContext closable = (ConfigurableApplicationContext) context;
            closable.close();
        }

    }

    /**
     * 框架banner
     */
    public static void bannerRuoyi()
    {
        System.out.println(ColorfulUtil.GREEN + "(♥◠‿◠)ﾉﾞ RUOYI STARTUP SUCCESS ლ(´ڡ`ლ)ﾞ\n" + ColorfulUtil.RESET);
    }

    /**
     * 业务系统banner
     */
    public static void bannerBusiness()
    {
        System.out.println(ColorfulUtil.CYAN + """
                     _       ____
                    | |_   _| __ )  __ _ _ __   __ _\s
                 _  | | | | |  _ \\ / _` | '_ \\ / _` |
                | |_| | |_| | |_) | (_| | | | | (_| |
                 \\___/ \\__,_|____/ \\__,_|_| |_|\\__, |
                """ + ColorfulUtil.WHITE +
                           "   :v1.0.0  STARTUP SUCCESS    " + ColorfulUtil.CYAN + "|___/\s"
                           + ColorfulUtil.RESET);
    }
}
